
module.exports = app => {

    return class HomeController extends app.Controller {

        /**
         * 社区话题首页
         * @returns {Promise<void>}
         */
        async index() {

            let id = this.ctx.params.id;

            let topic = await this.ctx.service.forum.detail({id});
            await this.ctx.render('forum/topic/index.js', {
                topic,
                currentId: id
            });
        }

        /**
         * 帖子详情
         * @returns {Promise<void>}
         */
        async detail() {
            let id = this.ctx.params.id;
            this.app.logger.info(id);
            let post = await this.service.post.detail({ id });

            let hot = await this.service.comment.list({ id });

            await this.ctx.render('forum/detail/index.js', {
                post,
                hot,
                currentId: id
            });
        }



    };
};
